Imports System.Data.SqlClient

Partial Public Class Survey
    Inherits System.Web.UI.Page

    Private strConnectionString As String = "Data Source=139.71.180.71;Initial Catalog=ProjectMgmt;User Id=surveyuser;Password=surveyuser;"


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        divSurvey.Visible = False
        Try
            divSurvey.Visible = False
            InsertSurveyData(1, DropDownList1.Text)
            InsertSurveyData(2, TextBox1.Text)
            InsertSurveyData(3, DropDownList2.Text)
            InsertSurveyData(4, DropDownList3.Text)
            InsertSurveyData(5, DropDownList4.Text)
            InsertSurveyData(6, DropDownList5.Text)
            InsertSurveyData(7, TextBox2.Text)
            InsertSurveyData(8, RadioButtonList1.SelectedItem.Text)
            InsertSurveyData(9, RadioButtonList2.SelectedItem.Text)
            Response.Write("Thanks for participating in the Survey.")
        Catch ex As Exception
            Response.Write("An Error Occurred while posting your response. Please Retry Again.")
            'Response.Write(ex.ToString)
        End Try
    End Sub


    Public Function InsertSurveyData(ByVal args1 As String, ByVal args2 As String) As Integer
        Dim objconn As New SqlConnection(strConnectionString)
        objconn.Open()

        Dim objcommand As New SqlCommand
        objcommand.Connection = objconn
        objcommand.CommandType = CommandType.StoredProcedure
        objcommand.CommandText = "ins_surveydata"

        objcommand.Parameters.AddWithValue("@QuestionId", args1)
        objcommand.Parameters.AddWithValue("@Response", args2)
        objcommand.Parameters.AddWithValue("@ClientIp", HttpContext.Current.Request.UserHostAddress)

        objcommand.CommandTimeout = 90000

        objcommand.ExecuteScalar()


    End Function
End Class
